package com.binance.security.html.sanitizer;

import org.owasp.html.HtmlChangeListener;

import javax.annotation.Nullable;

/**
 * Created by robin.wu on 2018/12/18.
 */
public class CustomHtmlChangeListener<CustomContext> implements HtmlChangeListener<CustomContext> {

    private StringBuilder discardSb;

    public CustomHtmlChangeListener(StringBuilder discardSb) {
        this.discardSb = discardSb;
    }

    @Override
    public void discardedTag(@Nullable CustomContext context, String elementName) {
        this.discardSb.append('<').append(elementName).append("> ");
    }

    @Override
    public void discardedAttributes(@Nullable CustomContext context, String tagName, String... attributeNames) {
        this.discardSb.append('<').append(tagName);
        for (String attributeName : attributeNames) {
            this.discardSb.append(' ').append(attributeName);
        }
        this.discardSb.append("> ");
    }
}
